package nayasis.common.util;

import java.text.ParseException;

import junit.framework.Assert;

import org.junit.Test;

public class StringUtilTest {

	@Test
	public void camel() throws ParseException {

	    Assert.assertEquals( StringUtil.getCamel("TEST_BOX"), "testBox" );

	}


	@Test
	public void lpad() {
	    
	    Assert.assertEquals( "0000000001", StringUtil.lpad( "1", '0', 10 ) );
	    Assert.assertEquals( "0000000022", StringUtil.lpad( "22", '0', 10 ) );
	    Assert.assertEquals( "12345", StringUtil.lpad( "12345", '0', 5) );
	    Assert.assertEquals( "1234", StringUtil.lpad( "12345", '0', 4) );

	    Assert.assertEquals( "0000", StringUtil.lpad( null, '0', 4) );
	    Assert.assertEquals( "0000", StringUtil.lpad( "", '0', 4) );
	    
	    Assert.assertEquals( "", StringUtil.lpad( "12345", '0', 0) );
	    
	}

	@Test
	public void rpad() {

	    Assert.assertEquals( "1234500000", StringUtil.rpad( "12345", '0', 10) );
	    Assert.assertEquals( "123450", StringUtil.rpad( "12345", '0', 6) );
	    Assert.assertEquals( "123", StringUtil.rpad( "12345", '0', 3) );
	    
	    Assert.assertEquals( "00000", StringUtil.rpad( "", '0', 5) );
	    Assert.assertEquals( "00000", StringUtil.rpad( null, '0', 5) );
	    
	}
	
}
